// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.core.skinnedmodel.advancedanimation;

import zombie.core.math.PZMath;

public final class AnimationVariableSlotCallbackInt extends AnimationVariableSlotCallback<Integer> {
    private int m_defaultValue = 0;

    public AnimationVariableSlotCallbackInt(String key, AnimationVariableSlotCallbackInt.CallbackGetStrongTyped callbackGet) {
        super(key, callbackGet);
    }

    public AnimationVariableSlotCallbackInt(
        String key, AnimationVariableSlotCallbackInt.CallbackGetStrongTyped callbackGet, AnimationVariableSlotCallbackInt.CallbackSetStrongTyped callbackSet
    ) {
        super(key, callbackGet, callbackSet);
    }

    public AnimationVariableSlotCallbackInt(String key, int defaultVal, AnimationVariableSlotCallbackInt.CallbackGetStrongTyped callbackGet) {
        super(key, callbackGet);
        this.m_defaultValue = defaultVal;
    }

    public AnimationVariableSlotCallbackInt(
        String key,
        int defaultVal,
        AnimationVariableSlotCallbackInt.CallbackGetStrongTyped callbackGet,
        AnimationVariableSlotCallbackInt.CallbackSetStrongTyped callbackSet
    ) {
        super(key, callbackGet, callbackSet);
        this.m_defaultValue = defaultVal;
    }

    public Integer getDefaultValue() {
        return this.m_defaultValue;
    }

    @Override
    public String getValueString() {
        return this.getValue().toString();
    }

    @Override
    public float getValueFloat() {
        return (float)this.getValue().intValue();
    }

    @Override
    public boolean getValueBool() {
        return this.getValueFloat() != 0.0F;
    }

    @Override
    public void setValue(String val) {
        this.trySetValue(Integer.valueOf(PZMath.tryParseInt(val, 0)));
    }

    @Override
    public void setValue(float val) {
        this.trySetValue(Integer.valueOf((int)val));
    }

    @Override
    public void setValue(boolean val) {
        this.trySetValue(Integer.valueOf(val ? 1 : 0));
    }

    @Override
    public AnimationVariableType getType() {
        return AnimationVariableType.Float;
    }

    @Override
    public boolean canConvertFrom(String val) {
        return true;
    }

    public interface CallbackGetStrongTyped extends AnimationVariableSlotCallback.CallbackGet<Integer> {
    }

    public interface CallbackSetStrongTyped extends AnimationVariableSlotCallback.CallbackSet<Integer> {
    }
}
